package com.niuwa.p2p.opr.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import com.niuwa.p2p.action.JsonAction;
import com.niuwa.p2p.entity.resource.Resource;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

/**
 * 得到用户资源
 * @author Dell
 *
 */

public class ResourceUtil extends  JsonAction  {
	 
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	List<Resource>   resourceList=new ArrayList<Resource>();

	Map<String, Object> session = ActionContext.getContext().getSession();
	
	public String checkSession(){
		
    if(session.get("user")==null){
    	return "/login";
    	
    	
    }		
	if (session.get("resource") == null) {
		return "/login";
	}
	 return NONE ;
	
	}
	public List<Resource> getSessionResources(){
		
		
      resourceList = (List<Resource>) session.get("resource");
		
		
		return resourceList;
	}

	
	public Map<String, Object> getSession() {
		return session;
	}
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}
	
	public List<Resource> getResourceList() {
		return resourceList;
	}
	public void setResourceList(List<Resource> resourceList) {
		this.resourceList = resourceList;
	}
	

}
